﻿CREATE VIEW [dbo].[ASMS_V_SettlementBillPackageItem]
	AS 
SELECT SBPI.*,
	P.Name as PackageName,
	PItem.[Name] as PackageItemName,
	PItem.TagData as PackageItemTagData,
	PItem.TagDataType as PackageItemTagDataType,
	PItem.Value as PackageItemValue,
	PItem.[Type] as PackageItemType
FROM ASMS_SettlementBillPackageItem as SBPI
	left join ASMS_PackageInstance as PInst on PInst.Id = SBPI.PackageInstanceId
	left join ASMS_PackageInstanceItem as PII on PII.Id = SBPI.PackageInstanceItemId
	left join ASMS_Package as P on P.Id = PInst.PackageId
	left join ASMS_PackageItem as PItem on PItem.Id = PII.PackageItemId
